// const promises = [Promise.resolve(1), Promise.resolve(2), Promise.resolve(3)];

// Promise.all(promises)
//   .then((values) => console.log(values))
//   .catch((error) => console.error(error));
import { getList, getDetail, getInfo } from "@/api/list.js";

const p1 = new Promise((resolve, reject) => {
  getList({ pageSize: 10, pageNum: 1 })
    .then((res) => {
      resolve(res.data);
    })
    .catch((err) => {
      reject(err);
    });
});
const p2 = new Promise((resolve, reject) => {
  getDetail({ id: 1 })
    .then((res) => {
      resolve(res.data);
    })
    .catch((err) => {
      reject(err);
    });
});
const p3 = new Promise((resolve, reject) => {
  getInfo()
    .then((res) => {
      resolve(res.data);
    })
    .catch((err) => {
      reject(err);
    });
});

Promise.all([p1, p2, p3])
  .then((res) => {
    // 此处的res就是p1, p2, p3传递过来的数组，是一个数组
    console.log(res);
  })
  .catch((err) => {
    console.log(err);
  });
